<%@ page language="java" contentType="text/html; charset=utf-8"	pageEncoding="utf-8"%>
<%@include file="header.jsp"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Add Product</title>
<script src="<%=contextPath %>/js/jquery_dialog.js"></script>
<link rel="stylesheet" type="text/css" href="<%=contextPath %>/js/jquery_dialog.css">
<link rel="stylesheet" type="text/css" href="<%=contextPath %>/admin/common.css">
<style>
.form-invalid {
background-color:#FFFFFF;
/*background-image:url(../images/invalid_line.gif);*/
border-color:#CC3300;
}
</style>
</head>
<body>
<script>
function setProductTypeValue(value){
	if ( value !=null && "" != value) {
		var begin = value.indexOf("#&*");
		if ( begin !=-1 ){
			var preValue = value.substring(0,begin);
			var sufValue = value.substring(begin+3,value.length);
			$("#typeName").val(sufValue);
			$("#productBean_typeId").val(preValue);
			//alert( $("#productBean_productType_id").val() );
		}
	}
}

$(document).ready(function(){
	    $("table tbody tr:even").addClass("tdbgcolor1"); 
	    $("table tbody tr:odd").addClass("tdbgcolor2"); 
}
);
	function checkAndSubmit(){
		var form = document.getElementById("productAddForm");
		/*
		if ( form.name.value == ""){
			alert("用户账号不能为空");
			form.name.focus();
			return false;
		}
		if ( form.password.value != form.passwordcfg.value){
			alert("两次输入密码不正确");
			form.password.focus();
			return false;
		}
		*/
		form.submit();
	}
</script>  
<div align="center">新增产品</div>
<form method="post" action="productAdd.action" id="productAddForm">
<table width="80%" border="0" cellpadding="3" cellspacing="1"  bgcolor="#FFFFFF" align="center">
	<tr>
		<td>选择产品类别</td>
		<td id="productType">
		<input type="text" name="typeName" id="typeName"/><input type="button" value="Select"  id='typeNameBtn' onclick="JqueryDialog.Open('', 'productTypeListSel.action?productTypeParenBean.parentId=<%=com.remist.common.Constant.LEVEL_ROOT %>', 300, 350,'typeNameBtn');"/>
		<input type="hidden"  name="productBean.typeId" id="productBean_typeId"/></td>
	</tr>
	<tr>
		<td>Item Code:</td>
		<td><input type="text" name="productBean.itemCode" id="itemCode"/></td>
	</tr>
 
	<tr>
		<td  >Price:</td>
		<td ><input  name="productBean.price" id="price"/></td>
	</tr>
	<tr>
		<td  >goldPrice:</td>
		<td ><input  name="productBean.goldPrice" id="goldPrice"/></td>
	</tr>
	<tr>
		<td  >silverPrice:</td>
		<td ><input  name="productBean.silverPrice" id="silverPrice"/></td>
	</tr>
	<tr>
		<td  >copperPrice:</td>
		<td ><input  name="productBean.copperPrice" id="copperPrice"/></td>
	</tr>
	<tr>
		<td  >currentPrice:</td>
		<td ><input  name="productBean.currentPrice" id="currentPrice"/></td>
	</tr>
	
	<tr>
	<td  >Material:</td>
		<td ><input  name="productBean.material" id="material" /></td>
	</tr>	
	<tr>
	<td  >weight:</td>
		<td ><input  name="productBean.weight" id="weight" /></td>
	</tr>	
	<tr>
	<td  >dimesion:</td>
		<td ><input  name="productBean.dimension" id="dimension" /></td>
	</tr>
	<tr>	
	<td  >Band Width:</td>
		<td ><input  name="productBean.bandWidth" id="bandWidth" /></td>
	</tr>

	
	<tr>	
	<td  >color:</td>
		<td ><input  name="productBean.color" id="color" /></td>
	</tr>
	<tr>	
		<td  >Size:</td>
		<td ><input  name="productBean.size" id="size" /></td>
	</tr>
	<tr>	
	<td  >necklaceLength:</td>
		<td ><input  name="productBean.necklaceLength" id="necklaceLength" /></td>
	</tr>
	<tr>	
	<td  >description:</td>
		<td ><input  name="productBean.description" id="description" /></td>
	</tr>
	<script>
		function showUploadWindow(id){
			var InfoW=620;
			var InfoH=400;
			var InfoUrl="../insert_images.jsp?uploadFolder=<%=com.remist.common.Constant.UPLOAD_PRODUCT %>";
			var str=window.showModalDialog(InfoUrl,"","dialogWidth="+InfoW+"px;dialogHeight="+InfoH+"px;center=yes;help=no;resizable=no;status=no;scroll=no");
			if ( str != undefined){
				addNew( str );
			}
		}	
		function addNew(value){
			var myDate=new Date();
			var millseconds = myDate.getMilliseconds();
			var table1 = $('#attachmentTable');
			$("#table的ID").find("tr").length
			/*var firstTr = table1.find('tbody>tr:first');*/
			var row = $("<tr id='"+millseconds+"'></tr>");
			var td = $("<td></td>");
			var begin = value.indexOf("|");
 	 		var imageId = value.substring(begin+1,value.length);
 	 		value =  value.substring(0,begin);
			begin = value.lastIndexOf("/")+1;
			var fileName = value.substring(begin,value.length);
			td.append($("<input type='hidden' name='imagesIds' value='"+imageId+"'/><input type='hidden' name='productBean.imageUrl' value='"+value+"'><a href='#' onclick=\"viewPic('"+value+"')\">"+fileName+"</a>&nbsp;&nbsp;<a href='#' onclick='removeRow("+millseconds+")'>remove</a>")	);
			row.append(td);
			table1.append(row);
		}
		function viewPic(picPath){
			window.open("<%=contextPath %>/"+picPath, "", "", "");
		}
		function removeRow(id){
			tr = $("#"+id );
		 	tr.remove();
		}
		 
		</script>
	<tr>	
	<td  >imageUrl:</td>
		<td >
			<table width="100%" id="attachmentTable">
				<tr><td></td><td></td><td></td></tr>
			</table>
			<input type="button" value="添加照片"  onClick="showUploadWindow('pic')"/>
		
		<%--
			<input  name="productBean.imageUrl" id="imageUrl" value="<s:property value='productBean.imageUrl'/>" />
		 --%>
		</td>
	</tr>	
	<%-- 
	<tr>
		<td  >类别:</td>
		<td  ><select name="userBean.level" id="level">
			<option value="1">管理员</option>
			<option value="2">员工</option>
		</select></td>
	</tr>
	 -->
 --%>
	<tr>
		<td colspan="2" ><input type="button" value="Save"  onclick="checkAndSubmit()"/>&nbsp;
		<input			type="button" value="reset" />
		<%--
		<input type="hidden" name="productBean.id" value="0" />
		 --%>
			&nbsp;
			<input	type="button" value="返回"  onclick="javascript:window.history.back();" />
			</td>
</table>
</form>
</body>
</html>
